package com.cbgolf.oa.model;

import android.support.v4.util.ArrayMap;
import com.cbgolf.oa.base.BaseModel;
import com.cbgolf.oa.entity.ChartBean;
import com.cbgolf.oa.entity.ChartData;
import com.cbgolf.oa.entity.ChartData.CaddieHistory;
import com.cbgolf.oa.entity.DateRange;
import com.cbgolf.oa.entity.ListBean;
import com.cbgolf.oa.entity.NetResponse;
import com.cbgolf.oa.entity.StatisticsBean;
import com.cbgolf.oa.manager.DataManager;
import com.cbgolf.oa.net.NetCallBack;
import com.cbgolf.oa.net.Web;
import com.cbgolf.oa.net.WebAPI;
import com.cbgolf.oa.presenter.IStatisticsPresenter;
import com.cbgolf.oa.util.DataUtil;
import com.cbgolf.oa.util.DateUtil;
import com.cbgolf.oa.util.ErrorUtil;
import com.cbgolf.oa.util.TextUtil;
import com.cbgolf.oa.util.Util;
import com.github.mikephil.charting.data.BarEntry;
import com.github.mikephil.charting.data.Entry;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

/**
 * Created by lq on 2017/9/13.
 */

public class StatisticsModel extends BaseModel {

  //time
  protected Calendar curCalendar = Calendar.getInstance();
  protected Calendar dayCalendar = Calendar.getInstance();
  protected Calendar weekCalendar = Calendar.getInstance();
  protected Calendar monthCalendar = Calendar.getInstance();
  protected Calendar quarterCalendar = Calendar.getInstance();
  protected Calendar yearCalendar = Calendar.getInstance();


  //var
  protected long startTime;
  protected long endTime;
  //
  protected long day = System.currentTimeMillis();
  protected long lastMonday;
  protected long lastSunday;
  protected long quarter;
  //index
  protected int weekIndex;
  protected int monthIndex;
  protected int yearIndex;
  //dt
  protected final int CUR = 0;
  protected final int DAY = CUR + 1;
  protected final int WEEK = DAY + 1;
  protected final int MONTH = WEEK + 1;
  protected final int QUARTER = MONTH + 1;
  protected final int YEAR = QUARTER + 1;
  protected int dateType = CUR;
  protected final int ALLTYPE = 0;
  protected final int INCLUDE = 1;
  protected final int NOTINCLUDE = 2;
  protected int dataChooseType;

  protected String[] dataTypes = new String[]{
      "TOTAL", "COME", "NOCOME"
  };

  protected List<ChartData> listLineData = new ArrayList<>();
  protected List<CaddieHistory> listCaddieThis = new ArrayList<>();
  protected List<CaddieHistory> listCaddieLast = new ArrayList<>();
  ArrayList<Entry> thisYearVals = new ArrayList<Entry>();
  ArrayList<Entry> lastYearVals = new ArrayList<Entry>();
  ArrayList<BarEntry> thisYearPawWayVals = new ArrayList<BarEntry>();
  ArrayList<BarEntry> lastYearPawWayVals = new ArrayList<BarEntry>();
  /**
   * bar x-name map
   */
  Map<Integer, String> payNameMap = new HashMap<>();
  List<ListBean> listNameId = new ArrayList<>();
  /**
   * key --name value--id
   */
  ArrayMap<String, String> nameIdMap = new ArrayMap<>();
  /**
   * bar x-name map
   */
  Map<Integer, String> idMap = new ArrayMap<>();
  TreeMap<Integer, String> lineNames = new TreeMap<>();
  List<String> listUserIds = new ArrayList<>();
  int startStep = 1000;
  //
  protected String allTimes;
  protected String allTimesCompare;
  protected String meanTimes;
  protected String timesCompare;
  protected String meanDuration;
  protected String durationCompare;
  protected List<StatisticsBean.PersonNum> listTimes = new ArrayList<>();
  protected List<StatisticsBean.PersonNumLast> listTimesLast = new ArrayList<>();
  protected List<ChartData> listBarThis = new ArrayList<>();
  protected List<ChartData> listBarLast = new ArrayList<>();
  /**
   * 打球人统计linechat data
   */
  protected List<ChartData> listPlayerLine = new ArrayList<>();
  /**
   * 打球人统计barchat data
   */
  protected List<ChartData> listBarData = new ArrayList<>();
  protected List<Integer> listTimesMax = new ArrayList<>();
  protected List<Integer> listLevelMax = new ArrayList<>();

  //class
//  protected final String BUSINESS_TAG = "business";
//  protected final String BOOK_TAG = "book";
//  protected final String CADDIE_TAG = "caddie";
//  private final String Bill_TAG = "bill";
//  private final String PLAYER_TAG = "player";
//  protected String classType = BUSINESS_TAG;

  protected int mType;

  protected String point = "";

  protected IStatisticsPresenter worker;

  public StatisticsModel(IStatisticsPresenter worker) {
    this.worker = worker;
  }

  public void setPoint(String point) {
    this.point = point;
  }

//  public void setClassType(int type) {
//    this.mType = type;
//  }

  public void getNext(int dateType, int dataChooseType) {
//        this.classType = clazz;
    this.dateType = dateType;
    this.dataChooseType = dataChooseType;
    switch (dateType) {
      case CUR:
      case DAY:
        dayCalendar.setTimeInMillis(day);//把当前时间赋给日历
        dayCalendar.add(Calendar.DAY_OF_MONTH, 1);
        dayCalendar.set(Calendar.HOUR_OF_DAY, 0);
        dayCalendar.set(Calendar.MINUTE, 0);
        dayCalendar.set(Calendar.SECOND, 0);
        day = dayCalendar.getTimeInMillis();
        startTime = dayCalendar.getTimeInMillis();
        dayCalendar.set(Calendar.HOUR_OF_DAY, 23);
        dayCalendar.set(Calendar.MINUTE, 59);
        dayCalendar.set(Calendar.SECOND, 59);
        endTime = dayCalendar.getTimeInMillis();
//                dayCalendar.add(Calendar.DAY_OF_MONTH, -1);
        worker.setDate(DateUtil.stampToDateyMd3(day + ""));
        if ((curCalendar.get(Calendar.MONTH) == dayCalendar.get(Calendar.MONTH))
            && (curCalendar.get(Calendar.DAY_OF_MONTH) <= dayCalendar.get(Calendar.DAY_OF_MONTH))) {
          worker.setNextTvLive(false);
//                    endTime = System.currentTimeMillis();
        }

        break;
      case WEEK:
        weekIndex++;
        setNextWeekDate();
        break;
      case MONTH:
        monthIndex++;
        setMonthDate();
        break;
      case QUARTER:
        setNextQuarter();
        break;
      case YEAR:
        yearIndex++;
        setYearDate();
        break;
      default:
        break;
    }
    loadData();
  }

  protected void setNextQuarter() {
    DateRange dr = DateUtil.getNextQuarter(quarter);
    if (null != dr) {
      startTime = dr.start;
      endTime = dr.end;
      if (System.currentTimeMillis() <= startTime
          || (System.currentTimeMillis() >= startTime && System.currentTimeMillis() <= endTime)) {
        worker.setDate("本季度");
        worker.setNextTvLive(false);
        quarter = System.currentTimeMillis();
//                endTime = DateUtil.getThisQuarter().end;
        return;
      }
      if (startTime > 0 && endTime > 0) {
        String startDate = DateUtil.stampToDateyMd3(startTime + "");
        String endDate = DateUtil.stampToDateMd(endTime + "");
        worker.setDate(startDate + "-" + endDate);
      }
    }
    if (startTime > 0) {
      quarter = startTime;
    }
  }

  protected void setNextWeekDate() {
    Calendar preWeekSundayCal = Calendar.getInstance();
    Calendar preWeekMondayCal = Calendar.getInstance();
    preWeekMondayCal.setTimeInMillis(lastMonday);
    preWeekSundayCal.setTimeInMillis(lastSunday);
    preWeekMondayCal.add(Calendar.DATE, 7);
    preWeekSundayCal.add(Calendar.DATE, 7);
    startTime = preWeekMondayCal.getTimeInMillis();
    endTime = preWeekSundayCal.getTimeInMillis();
    if (preWeekMondayCal.getTimeInMillis() <= System.currentTimeMillis()
        && preWeekSundayCal.getTimeInMillis() >= System.currentTimeMillis()) {
      worker.setDate("本周");
      worker.setNextTvLive(false);
      endTime = mType == DataManager.STATISTICS_BILL_ALL ? System.currentTimeMillis()
          : DateUtil.getEndDayOfWeek().getTime();
      startTime = mType == DataManager.STATISTICS_BILL_ALL ? System.currentTimeMillis() : startTime;
      return;
    }
    lastMonday = preWeekMondayCal.getTimeInMillis();
    lastSunday = preWeekSundayCal.getTimeInMillis();
    String monday = DateUtil.stampToDateyMd3(lastMonday + "");
    String sunday = DateUtil.stampToDateMd(lastSunday + "");
    worker.setDate(monday + "-" + sunday);
  }

  public void getLast(int dateType, int dataChooseType) {
    this.dataChooseType = dataChooseType;
    this.dateType = dateType;
//        this.classType = clazz;
    switch (dateType) {
      case CUR:
      case DAY:
        dayCalendar.setTimeInMillis(day);//把当前时间赋给日历
        dayCalendar.add(Calendar.DAY_OF_MONTH, -1);  //设置为前一天
        dayCalendar.set(Calendar.HOUR_OF_DAY, 0);
        dayCalendar.set(Calendar.MINUTE, 0);
        dayCalendar.set(Calendar.SECOND, 0);
        dayCalendar.set(Calendar.MILLISECOND, 0);
        day = dayCalendar.getTimeInMillis();
        startTime = dayCalendar.getTimeInMillis();
        dayCalendar.set(Calendar.HOUR_OF_DAY, 23);
        dayCalendar.set(Calendar.MINUTE, 59);
        dayCalendar.set(Calendar.SECOND, 59);
        endTime = dayCalendar.getTimeInMillis();
        worker.setDate(DateUtil.stampToDateyMd3(day + ""));
        break;
      case WEEK:
        weekIndex--;
        setLastWeekDate(weekIndex);
        break;
      case MONTH:
        monthIndex--;
        setMonthDate();
        break;
      case QUARTER:
        setLastQuarterDate();
        break;
      case YEAR:
        yearIndex--;
        setYearDate();
        break;
      default:
        break;
    }
    loadData();

  }

  protected void setYearDate() {
    Calendar c = Calendar.getInstance();
    c.setTime(new Date());
    c.add(Calendar.YEAR, yearIndex);
    c.set(Calendar.MONTH, Calendar.JANUARY);
    c.set(Calendar.DATE, 1);
    c.set(Calendar.HOUR_OF_DAY, 0);
    c.set(Calendar.MINUTE, 0);
    c.set(Calendar.SECOND, 0);
    c.set(Calendar.MILLISECOND, 0);
    startTime = c.getTimeInMillis();
    c.set(Calendar.MONTH, Calendar.DECEMBER);
    c.set(Calendar.DATE, 31);
    c.set(Calendar.HOUR_OF_DAY, 23);
    c.set(Calendar.MINUTE, 59);
    c.set(Calendar.SECOND, 59);
    endTime = c.getTimeInMillis();
    if (startTime >= System.currentTimeMillis()
        || (System.currentTimeMillis() >= startTime && System.currentTimeMillis() <= endTime)) {
      worker.setDate(DateUtil.stampToDateyMd3(String.valueOf(startTime)) + "-" + DateUtil
          .stampToDateMd(System.currentTimeMillis() + ""));
      worker.setNextTvLive(false);
//            endTime = System.currentTimeMillis();
      return;
    }
    worker.setDate(
        DateUtil.stampToDateyMd3(startTime + "") + "-" + DateUtil.stampToDateMd(endTime + ""));
  }

  protected void setLastQuarterDate() {
    DateRange dr = DateUtil.getLastQuarter(quarter);
    if (null != dr) {
      startTime = dr.start;
      endTime = dr.end;
      if (startTime > 0 && endTime > 0) {
        String startDate = DateUtil.stampToDateyMd3(startTime + "");
        String endDate = DateUtil.stampToDateMd(endTime + "");
        worker.setDate(startDate + "-" + endDate);
      }
    }
    if (endTime > 0) {
      quarter = endTime;
    }
  }

  protected void setMonthDate() {
    Calendar c = Calendar.getInstance();
    Calendar c1 = Calendar.getInstance();
    c.add(Calendar.MONTH, monthIndex);
    c1.add(Calendar.MONTH, monthIndex);
    int MaxDay = c.getActualMaximum(Calendar.DAY_OF_MONTH);
    int minDay = c.getActualMinimum(Calendar.DAY_OF_MONTH);
    //按你的要求设置时间
    c.set(c.get(Calendar.YEAR), c.get(Calendar.MONTH), MaxDay, 23, 59, 59);
    c1.set(c1.get(Calendar.YEAR), c1.get(Calendar.MONTH), minDay, 0, 0, 0);
    startTime = c1.getTimeInMillis();
    if (c1.getTimeInMillis() <= System.currentTimeMillis() &&
        c.getTimeInMillis() >= System.currentTimeMillis()) {
      worker.setNextTvLive(false);
      worker.setDate("本月");
      endTime = DateUtil.getEndDayOfMonth().getTime();
      return;
    }
    endTime = c.getTimeInMillis();
    //按格式输出
    SimpleDateFormat sdfM = new SimpleDateFormat("yyyy/MM/dd");
    SimpleDateFormat sdfD = new SimpleDateFormat("dd");
    String month = sdfM.format(c1.getTime());
    String lastDay = sdfD.format(c.getTime());
    worker.setDate(month + "-" + lastDay);
  }

  protected void setLastWeekDate(int index) {
    Calendar sundayCal = Calendar.getInstance();
    Calendar mondayCal = Calendar.getInstance();
    sundayCal.setFirstDayOfWeek(Calendar.MONDAY);
    mondayCal.setFirstDayOfWeek(Calendar.MONDAY);

    mondayCal.add(Calendar.DATE, index * 7);
    sundayCal.add(Calendar.DATE, index * 7);
    mondayCal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
    mondayCal.set(Calendar.HOUR_OF_DAY, 0);
    mondayCal.set(Calendar.MINUTE, 0);
    mondayCal.set(Calendar.SECOND, 0);
    sundayCal.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
    sundayCal.set(Calendar.HOUR_OF_DAY, 23);
    sundayCal.set(Calendar.MINUTE, 59);
    sundayCal.set(Calendar.SECOND, 59);
    lastMonday = mondayCal.getTimeInMillis();
    lastSunday = sundayCal.getTimeInMillis();
    String monday = DateUtil.stampToDateyMd3(lastMonday + "");
    String sunday = DateUtil.stampToDateMd(lastSunday + "");
    worker.setDate(monday + "-" + sunday);
    startTime = mondayCal.getTimeInMillis();
    endTime = sundayCal.getTimeInMillis();
  }

  public void getCurData(int type) {
    this.dataChooseType = 0;
    this.mType = type;
    if (mType == DataManager.STATISTICS_BILL_ALL) {
      this.dateType = WEEK;
      weekCalendar.setTimeInMillis(System.currentTimeMillis());
    } else {
      this.dateType = CUR;
    }
    curCalendar.setTimeInMillis(System.currentTimeMillis());
    curCalendar.set(Calendar.HOUR_OF_DAY, 0);
    curCalendar.set(Calendar.MINUTE, 0);
    curCalendar.set(Calendar.SECOND, 0);
    curCalendar.set(Calendar.MILLISECOND, 0);
    startTime = curCalendar.getTimeInMillis();
    curCalendar.set(Calendar.HOUR_OF_DAY, 23);
    curCalendar.set(Calendar.MINUTE, 59);
    curCalendar.set(Calendar.SECOND, 59);
    endTime = curCalendar.getTimeInMillis();
    loadData();
  }

  protected void loadData() {
    resetData();
    if (!Util.isNetWorkConnected()) {
      worker.getDataFail(ErrorUtil.NONET);
      return;
    }
    getData();

  }

  float lineLeftMax = 100;
  float barLeftMax = 100;

  private void resetData() {
    String timeType = "较前日";
    switch (dateType) {
      case CUR:
      case DAY:
        timeType = "较前日";
        break;
      case WEEK:
        timeType = "较上周";
        break;
      case MONTH:
        timeType = "较上月";
        break;
      case QUARTER:
        timeType = "较上季";
        break;
      case YEAR:
        timeType = "较上年";
        break;
      default:
        break;
    }
    allTimesCompare = timeType + "0%";
    allTimes = "0";
    meanTimes = "0";
    timesCompare = timeType + "0%";
    meanDuration = "0";
    durationCompare = timeType + "0%";
    allNum = 0;
    inCludeNum = 0;
    noCludeNum = 0;
    lastMoneyMax = 0;
    thisMoneyMax = 0;
    lastWayMax = 0;
    thisWayMax = 0;
    allCompare = timeType + "0%";
    InCompare = timeType + "0%";
    noCludeCompare = timeType + "0%";
    lineLeftMax = 0;
    barLeftMax = 0;
    thisYearVals.clear();
    lastYearVals.clear();
    thisYearPawWayVals.clear();
    lastYearPawWayVals.clear();
    lineNames.clear();
    payNameMap.clear();
  }

  protected void getCaddieData(StatisticsBean bean) {

  }

  protected void getBillData(StatisticsBean bean) {

  }

  protected void getBookData(StatisticsBean bean) {

  }

  protected void getBussinessData(StatisticsBean bean) {

  }

  protected void resetIndex() {
    weekIndex = 0;
    monthIndex = 0;
    yearIndex = 0;
  }

  public void setFilterDateViews(int dateType, int dataChooseType) {
//        this.classType = clazz;
    this.dataChooseType = dataChooseType;
    this.dateType = dateType;
    worker.setNextTvLive(false);
    worker.setFilterViews(dateType);
    resetIndex();
    getTheTime();
    loadData();
  }

  public void getTheTime() {
    switch (dateType) {
      case DAY:
        day = System.currentTimeMillis();
        dayCalendar.setTimeInMillis(System.currentTimeMillis());
        dayCalendar.set(Calendar.HOUR_OF_DAY, 0);
        dayCalendar.set(Calendar.MINUTE, 0);
        dayCalendar.set(Calendar.SECOND, 0);
        dayCalendar.set(Calendar.MILLISECOND, 0);
        startTime = dayCalendar.getTimeInMillis();
        dayCalendar.set(Calendar.HOUR_OF_DAY, 23);
        dayCalendar.set(Calendar.MINUTE, 59);
        dayCalendar.set(Calendar.SECOND, 59);
        endTime = dayCalendar.getTimeInMillis();
        dayCalendar.setTimeInMillis(System.currentTimeMillis());
        worker.setDate(DateUtil.stampToDateyMd3(System.currentTimeMillis() + ""));
        break;
      case WEEK:
        weekCalendar.setTimeInMillis(System.currentTimeMillis());
        startTime = DateUtil.getBeginDayOfWeek().getTime();
        endTime = DateUtil.getEndDayOfWeek().getTime();
        if (mType == DataManager.STATISTICS_BILL_ALL) {
          endTime = System.currentTimeMillis();
        }
        break;
      case MONTH:
        monthCalendar.setTimeInMillis(System.currentTimeMillis());
        startTime = DateUtil.getBeginDayOfMonth().getTime();
        endTime = DateUtil.getEndDayOfMonth().getTime();
        if (mType == DataManager.STATISTICS_BILL_ALL) {
          endTime = System.currentTimeMillis();
        }
        break;
      case QUARTER:
        quarter = System.currentTimeMillis();
        quarterCalendar.setTimeInMillis(System.currentTimeMillis());
        DateRange dr = DateUtil.getThisQuarter();
        if (null != dr) {
          startTime = dr.start;
          endTime = dr.end;
        }

        break;
      case YEAR:
        yearCalendar.setTimeInMillis(System.currentTimeMillis());
        startTime = DateUtil.getBeginDayOfYear().getTime();
        endTime = DateUtil.getEndDayOfYear().getTime();
        if (mType == DataManager.STATISTICS_BILL_ALL) {
          endTime = System.currentTimeMillis();
        }
        break;
      default:
        break;
    }
  }

  public void getChooseTypeData(int dateType, int dataChooseType) {
    this.dataChooseType = dataChooseType;
    this.dateType = dateType;
    loadData();
  }

  public void getData() {
    worker.reset();
    String url = WebAPI.book_statistics_get;
    Map<String, String> map = new HashMap<>();
    switch (mType) {
      case DataManager.STATISTICS_BUSINESS_ALL:
        url = WebAPI.outletTotal_get;
        map.put("startTime", TextUtil.Text(startTime));
        map.put("endTime", TextUtil.Text(endTime));
        map.put("code", point);
        map.put("payIncome",
            (dataChooseType == INCLUDE) ? "YES" : (dataChooseType == NOTINCLUDE ? "NO" : ""));
        break;
      case DataManager.STATISTICS_BOOK_ALL:
        url = WebAPI.book_statistics_get;
        map.put("startTime", startTime + "");
        map.put("endTime", endTime + "");
        if (dataChooseType < dataTypes.length) {
          map.put("reserveType", dataTypes[dataChooseType]);
        }
        break;
      case DataManager.STATISTICS_CADDIE_ALL:
        url = WebAPI.caddie_statistics_day_get;
        switch (dateType) {
          case WEEK:
            url = WebAPI.caddie_statistics_week_get;
            break;
          case MONTH:
            url = WebAPI.caddie_statistics_month_get;
            break;
          case QUARTER:
            url = WebAPI.caddie_statistics_quarter_get;
            break;
          case YEAR:
            url = WebAPI.caddie_statistics_year_get;
            break;
          default:
            break;
        }
        map.put("day", TextUtil.Text(endTime));
        break;
      case DataManager.STATISTICS_BILL_ALL:
        url = WebAPI.billdata_select_byweek_get;
        if (dateType == MONTH) {
          url = WebAPI.billdata_select_bymonth_get;
        } else if (dateType == YEAR) {
          url = WebAPI.billdata_select_byyear_get;
        }
        map.put("day", TextUtil.Text(endTime));
        break;
      case DataManager.STATISTICS_PLAYER_ALL:
        url = WebAPI.statistics_player_get;
        map.put("startTime", TextUtil.Text(startTime));
        map.put("endTime", TextUtil.Text(endTime));
        map.put("come", String.valueOf(dataChooseType == INCLUDE ?
            true
            : (dataChooseType == NOTINCLUDE ? false : "")));
        break;
      default:
        break;

    }
    map.put("token", DataUtil.getToken());
    worker.showProgress();
    Web.getOK(url, map, new NetCallBack(response -> {
      worker.stopProgress();
      setData(response);
    }));

  }

  protected void setData(NetResponse response) {
    if (200 != response.statusCode) {
      worker.getDataFail(response.errorMsg);
      return;
    }
    StatisticsBean m = (StatisticsBean) getBean(response, StatisticsBean.class);
    if (null == m) {
      worker.getDataFail(ErrorUtil.NODATA);
      return;
    }
    getTheDatas(m);
  }

  private void getTheDatas(StatisticsBean bean) {
    switch (mType) {
      case DataManager.STATISTICS_BUSINESS_ALL:
        getBussinessData(bean);
        break;
      case DataManager.STATISTICS_BOOK_ALL:
        getBookData(bean);
        break;
      case DataManager.STATISTICS_CADDIE_ALL:
        getCaddieData(bean);
        break;
      case DataManager.STATISTICS_BILL_ALL:
        getBillData(bean);
        break;
      case DataManager.STATISTICS_PLAYER_ALL:
        covertPlayerData(bean);
        break;
      default:
        break;

    }
  }

  protected void covertPlayerData(StatisticsBean bean) {

  }

  float allNum;
  float inCludeNum;
  float noCludeNum;

  String allCompare = "";
  String InCompare = "";
  String noCludeCompare = "";

  int lastMoneyMax = 0;
  int thisMoneyMax = 0;
  int lastWayMax = 0;
  int thisWayMax = 0;
  int xLableCount = 0;
  int xMin = 1;
  int xMax = 12;


  protected void setCallBackData() {
    String timeType = "较前日";
    switch (dateType) {
      case CUR:
      case DAY:
        timeType = "较前日";
        xLableCount = 12;
        xMin = 2;
        xMax = 24;
        break;
      case WEEK:
        timeType = "较上周";
        xLableCount = 7;
        xMin = 1;
        xMax = 7;
        break;
      case MONTH:
        timeType = "较上月";
        xLableCount = 10;
        xMin = 3;
        xMax = 30;
        break;
      case QUARTER:
        timeType = "较上季";
        xLableCount = 6;
        xMin = 1;
        xMax = 6;
        break;
      case YEAR:
        timeType = "较上年";
        xLableCount = 12;
        xMin = 1;
        xMax = 12;
        break;
      default:
        break;
    }
    allCompare = Util.isNull(allCompare) ? timeType + "0%" : timeType + allCompare;
    InCompare = Util.isNull(InCompare) ? timeType + "0%" : timeType + InCompare;
    noCludeCompare = Util.isNull(noCludeCompare) ? timeType + "0%" : timeType + noCludeCompare;

    int lineLeftMax = thisMoneyMax > lastMoneyMax ? thisMoneyMax : lastMoneyMax;
    int barLeftMax = thisWayMax > lastWayMax ? thisWayMax : lastWayMax;

    ChartBean bean = new ChartBean();
    bean.allNum = allNum;
    bean.inNum = inCludeNum;
    bean.noCludeNum = noCludeNum;
    bean.allRatio = allCompare;
    bean.inRatio = InCompare;
    bean.noCludeRatio = noCludeCompare;

    bean.lineLeftMax = lineLeftMax < 10 ? 12 : lineLeftMax;
    bean.lineXLableCount = xLableCount;
    bean.lineYLableCount = 7;
    bean.lineXMax = xMax;
    bean.lineXMin = xMin;

    bean.barYLableCount = 7;
    bean.barLeftMax = barLeftMax < 10 ? 12 : barLeftMax;

    bean.BarthisVals = thisYearPawWayVals;
    bean.BarlastVals = lastYearPawWayVals;
    bean.BarMap = payNameMap;
    bean.idMap = idMap;
    bean.nameIdMap = nameIdMap;
    bean.barXLableCount = (!Util.listIsNull(listBarData)) ? listBarData.size() : 0;

    bean.LinethisVals = thisYearVals;
    bean.LinelastVals = lastYearVals;
    bean.dateType = dateType;
    bean.listUserId = listUserIds;
    bean.startTime = startTime;
    bean.endTime = endTime;
    bean.listBarData = listBarData;
    worker.getDataSuccess(bean);
  }


}
